#include "PGLPipeline.h"

PGL::pglPipelineState::pglPipelineState()
	:runEvent(NULL)
{

}

cl_int PGL::pglPipelineState::setArgs()
{
	cl_int err;

	for(unsigned int i=0; i<arguments.size(); i++)
	{
		err = clSetKernelArg(kernel,i,arguments[i].argsize,arguments[i].argptr);
		if(err)
			return err;
	}

	return err;
}

cl_int PGL::pglPipelineState::enqueue(cl_command_queue cmdQueue, vector<cl_event> &eventVector)
{
	cl_int err;

	// Set arguments
	err = setArgs();
	if(err)
		return err;

	// Enqueue kernel
	err = clEnqueueNDRangeKernel(
		cmdQueue,
		kernel,
		dimensions,
		NULL,
		globalWorkSize,
		localWorkSize,
		eventVector.size(),
		eventVector.size() ? &eventVector[0] : NULL,
		&runEvent);

	eventVector.push_back(runEvent);

	return err;
}

PGL::pglPipeline::pglPipeline()
{

}

cl_int PGL::pglPipeline::enqueue()
{
	return CL_SUCCESS;
}
